
;$(function() {
	getDeptList();
	get();
});


function get(){
	$.ajax({
        url: ctxPath+"/supervise/statistics/getStatistics",
        type: 'POST',
        data:{userId:$("#user_select").val(),startDate:$("#startDate").val(),endDate:$("#endDate").val(),deptId:$("#dept_select").val()},
        success: function(d){
        	var success = d.success;
        	 if(success==true){
        	if(d.data!=null){
        		var data = d.data;
        		$("#work_all").html(data.work_all);
        		$("#work_internal").html(data.work_internal);
        		$("#work_visit").html(data.work_visit);
        		$("#complete_all").html(data.complete_all);
        		$("#complete_internal").html(data.complete_internal);
        		$("#complete_visit").html(data.complete_visit);
        		$("#complete_visit").html(data.complete_visit);
        		$("#internal_satisfaction").html(data.internal_satisfaction);
        		$("#internal_basic").html(data.internal_basic);
        		$("#internal_no").html(data.internal_no);
        		$("#visit_satisfaction").html(data.visit_satisfaction);
        		$("#visit_basic").html(data.visit_basic);
        		$("#visit_no").html(data.visit_no);
        	}
        	}
        	 
	}
   })
}


/**
 * 获取组织机构
 * @returns
 */
function getDeptList(){
	$.ajax({
        url: "/agency/dept/getAllList",
        type: 'GET',
        success: function(d){
        	var success = d.success;
        	 if(success==true){
        	if(d.data!=null){
        		var result ='<option value="">全局</option>';
        		var deptId="";
        	$.each(d.data,function(i,item){
//        		if(i==0){
//        			deptId=item.id;
//        		}
        		result+='<option value="'+item.id+'">'+item.name+'</option>';	
        	})
        	$("#dept_select").html(result);
//        	getUserList(deptId);
        	}	 
        	}
        	 
	}
   })
}


/**
 * 获取机构下的人员
 * @returns
 */
function getUserList(deptId){
	var result ='<option value="">请选择</option>';
	if(deptId==null||deptId==''){
		$("#user_select").html(result);
		return;
	}
	$.ajax({
		url: "/agency/user/findByDeptId/"+deptId,
		type: 'GET',
		success: function(d){
			var success = d.success;
			if(success==true){
				if(d.data!=null){
					$.each(d.data,function(i,item){
						result+='<option value="'+item.userId+'">'+item.userName+'</option>';	
					})
					$("#user_select").html(result);
				}	 
			}
			
		}
	})
}
